﻿using UnityEngine;
using UnityEngine.UI;

namespace SuperScrollView
{
    public class BannerItem : MonoBehaviour
    {
        public delegate void OnSelectDelegate(BannerItem item);
        public delegate void OnShowDelegate(BannerItem item);
        public int mValue;
        public Text mText;
        public Image mIcon;
        public Image mBtn;
        public OnSelectDelegate OnSelectItem { set; get; }
        public OnShowDelegate OnShowItem { set; get; }

        public GameObject mMask;


        public void Init()
        {
            ClickEventListener listener = ClickEventListener.Get(mBtn.gameObject);
            listener.SetClickEventHandler(OnClickSelect);
        }

        public void OnClickSelect(GameObject obj)
        {
            OnSelectItem?.Invoke(this);
        }

        public int Value
        {
            get
            {
                return mValue;
            }
            set
            {
                mValue = value;
            }
        }

        public void SetItemData(int value)
        {
            Value = value;
            OnShowItem?.Invoke(this);
        }

        public void SetShow(bool isShow)
        {
            mMask.SetActive(!isShow);
        }

    }
}

